import { FormRules } from "element-plus"

export const formRules: FormRules = {
  workName: [{ type: "string", required: true, min: 2, max: 20, message: "请输入职位名称", trigger: "blur" }],
  studyingExperience: [
    { type: "number", required: true, min: 0, max: 6, message: "请输入正确的学历", trigger: "change" }
  ],
  workAddress: [
    {
      trigger: "change",
      required: true,
      validator: (rule, val, cb) => {
        if (
          Object.prototype.toString.call(val) === "[object Array]" &&
          val.length <= 3 &&
          val.every((li: any) => typeof Number(li) === "number")
        ) {
          cb()
        } else {
          cb("工作地址不正确")
        }
      }
    }
  ],
  workDescription: [
    {
      type: "string",
      required: true,
      min: 20,
      max: 700,
      trigger: "blur",
      message: "工作描述至少20个字，至多不超过700字"
    }
  ],
  workPrice: [{ type: "number", required: true, min: 1, max: 6, message: "请输入正确的薪资范围", trigger: "change" }],
  workTime: [{ type: "number", required: true, min: 0, max: 5, message: "请输入正确的工作经验范围", trigger: "change" }]
}
